const path = require("path");
const commonCSS = path.resolve(__dirname, "src/assets/less/common.less");
const pkg = require("./package");
const isProduction = process.env.NODE_ENV === "production";
// const serve = "http://172.30.3.74:5580";
const serve = "https://service.neuqsoft.com/ggfw/citizen/demo";

module.exports = {
  // publicPath: isProduction ? `/ggfw/resyin/` : "/",
  publicPath: isProduction ? `./` : "/",
  // publicPath: isProduction ? `./` : "/",

  indexPath: "console-index.html",

  assetsDir: "static",

  outputDir: `dist-${pkg.name}-${pkg.version}`,

  productionSourceMap: true,

  lintOnSave: true,

  devServer: {
    port: 9898,
    proxy: {
      "/api": { target: serve, changeOrigin: true }
      // "/api": { target: "https://service.neuqsoft.com/ggfw/citizen/demo", changeOrigin: true }
    }
  },

  pluginOptions: {
    // less 变量全局可用 style-resources-loader & vue-cli-plugin-style-resources-loader
    // https://www.npmjs.com/package/style-resources-loader
    "style-resources-loader": {
      preProcessor: "less",
      patterns: [commonCSS]
    }
  },

  configureWebpack: config => {
    if (isProduction) {
      // 生产环境移除 console.* terser-webpack-plugin
      // https://www.npmjs.com/package/terser-webpack-plugin
      config.optimization.minimizer[0].options.terserOptions.compress.drop_console = true;
    }
    // config.plugins.push();
  },

  chainWebpack: config => {
    config.plugin("html").tap(args => {
      args[0].version = pkg.version;
      return args;
    });
  },

  css: {
    loaderOptions: {
      less: {
        // ant design 0f vue UI 组件主题定制
        // https://www.antdv.com/docs/vue/customize-theme-cn/
        // modifyVars: {
        //   "primary-color": "#1DA57A",
        //   "link-color": "#1DA57A",
        //   "border-radius-base": "2px"
        // },
        javascriptEnabled: true
      }
    }
  }
};
